<?php
/**
 * Created by PhpStorm.
 * User: Michael Ma
 * Date: 2017/4/16
 * Time: 21:20
 */

header("Content-Type: text/plain;charset=utf-8");
header("Access-Control-Allow-Origin:*");
header("Access-Control-Methods:POST,GET");

//载入user类
require_once ("classes/user.php");

//接受前台数据
$id = isset($_POST['id']) ? $_POST['id'] : '';                              //用户id
$name = isset($_POST['name']) ? $_POST['name'] : '';                        //用户名
$pic = isset($_POST['pic']) ? $_POST['pic'] : '';                           //用户头像
$psw = isset($_POST['psw']) ? $_POST['psw'] : '';                           //用户密码
$offerState = isset($_POST['offerState']) ? $_POST['offerState'] : '';      //用户提供技能帮助状态
$offerSkill = isset($_POST['offerSkill']) ? $_POST['offerSkill'] : '';      //用户提供帮助技能

//实例化register类，调用方法插入类
$updateRegister = new User();
$result1 = $updateRegister -> updateUser($id,$name,$pic,$psw);
$result2 = $updateRegister -> updateOfferSkill($id,$offerSkill,$offerState);

//异常处理
if(!$result1){
    $error = "";
}else if(!$result2){
    $error = "";
}else{
    $selectName = new User();
    $result3 = $selectName -> selectName($name);
    if ($result3 = '0')
        $error = "yes";
    else
        $error = "";
}

echo json_encode($error,JSON_UNESCAPED_UNICODE);

?>